import $axios from 'utils/Request'

/**
 * 获取资源列表
 */
export const getPermissionPage = data => {
    return $axios({
        url: '/api/permission-do/v1',
        method: 'get',
        data
    });
}

/**
 * 获取所有资源
 * @param {*} data 
 */
export const getPermissionList = data => {
    return $axios({
        url: '/api/permission-do/v1/list',
        method: 'get',
        data
    });
}

/**
 * 获取资源详情
 * @param {id} data 
 */
export const getPermissionById = data => {
    return $axios({
        url: '/api/permission-do/v1/' + data.id,
        method: 'get',
        data
    });
}

/**
 * 保存资源
 * @param {*} data 
 */
export const savePermission = data => {
    return $axios({
        url: '/api/permission-do/v1',
        method: 'post',
        data
    });
}

/**
 * 删除资源
 * @param {id} data 
 */
export const deletePermissionById = data => {
    return $axios({
        url: '/api/permission-do/v1/' + data.id,
        method: 'delete',
        data
    });
}

/**
 * 修改资源信息
 * @param {*} data 
 */
export const updatePermissionById = data => {
    return $axios({
        url: '/api/permission-do/v1/' + data.id,
        method: 'put',
        data
    });
}

export const updatePermissionState = data => {
    return $axios({
        url: '/api/permission-do/v1/' + data.id,
        method: 'patch',
        data
    });
}

/**
 * 以tree的形式展示所有资源信息
 * @param {*} data 
 */
export const getPermissionForTree = data => {
    return $axios({
        url: '/api/permission-do/v1/getPermissionForTree',
        method: 'get',
        data
    });
}

/**
 * 以tree的形式展示所有资源信息:不分页
 * @param {*} data 
 */
export const getPermissionForTreeList = data => {
    return $axios({
        url: '/api/permission-do/v1/getPermissionForTreeList',
        method: 'get',
        data
    });
}